<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<head th:include="/base/common_css('test')">
<body>
<div th:include="/base/common_banner"></div>
<!-- Main content starts -->

<div class="content">
    <!-- Sidebar -->
    <div th:include="/base/common_menu"></div>
    <!-- Sidebar
    <div class="sidebar">
        <div class="sidebar-dropdown"><a href="#">Navigation</a></div>

    </div>-->
    <!-- Matter -->
    <div class="mainbar">
        <!-- Page heading -->
        <div th:include="/base/common_pageHeader"></div>

        <div class="matter">
            <div class="container">
                <div class="row">
                    <div class="col-md-6">


                        <div class="widget wgreen">

                            <div class="widget-head">
                                <div class="pull-left">菜单编辑</div>
                                <div class="widget-icons pull-right">
                                    <a href="#" class="wminimize"><i class="icon-chevron-up"></i></a>
                                    <a href="#" class="wclose"><i class="icon-remove"></i></a>
                                </div>
                                <div class="clearfix"></div>
                            </div>

                            <div class="widget-content">
                                <div class="padd">

                                    <!-- Form starts.  -->
                                    <form class="form-horizontal" role="form" action="#" method="post">

                                        <div class="modal-body">
                                            <form action="#" method="post"
                                                  enctype="multipart/form-data">
                                                <input class="col-lg-4 form-control " type="hidden" id="menuId"
                                                       th:value="${menuId}">
                                                <div class="form-group">
                                                    <label class="col-lg-4 control-label">菜单名</label>
                                                    <div class="col-lg-8">
                                                        <input type="text" th:value="${menuName}" class="form-control"
                                                               id="menuName" placeholder="菜单名">
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-lg-4 control-label">菜单描述</label>
                                                    <div class="col-lg-8">
                                                        <input type="text" th:value="${menuDescription}"
                                                               class="form-control"
                                                               id="menuDescription" placeholder="菜单描述">
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-lg-4 control-label">菜单Url</label>
                                                    <div class="col-lg-8">
                                                        <input type="text" th:value="${menuUrl}" class="form-control"
                                                               id="menuUrl" placeholder="菜单Url">
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-lg-4 control-label">父级菜单</label>
                                                    <div class="col-lg-8">
                                                        <select id="menuParent" class="selectpicker show-tick form-control">
                                                            <option value="-1">==默认==</option>
                                                            <option th:each="menu, menuStat:${menuList}"
                                                                    th:value="${menu.menuId}"
                                                                    th:text="${menu.menuName}"
                                                                    th:selected="${menu.menuName == menuParent}"></option>
                                                        </select>

                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-lg-4 control-label">菜单类型</label>
                                                    <div class="col-lg-8">
                                                        <select id="menuType"
                                                                class="selectpicker show-tick form-control">
                                                            <option th:each="menuTypes:${menuTypeList}"
                                                                    th:value="${menuTypes.key}" th:text="${menuTypes.value}"
                                                                    th:selected="${menuTypes.key == menuType}"></option>
                                                        </select>

                                                    </div>
                                                </div>
                                            </form>
                                        </div>
                                    </form>
                                    <div class="modal-footer">
                                        <button type="button" onclick="saveMenu()"
                                                class="btn btn-success">保存
                                        </button>
                                        <button type="button" class="btn btn-cancel" onclick="cancles()">取消
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<!-- Mainbar ends -->
<div class="clearfix"></div>

</div>
<!-- Content ends -->

<div th:include="/base/common_footer"></div>
<!-- Scroll to top -->
<span class="totop"><a href="#"><i class="icon-chevron-up"></i></a></span>
<!--js????-->
<div th:include="/base/common_js"></div>
<script type="text/javascript">

    function cancles() {
        window.location.href  = "/view/menuList?pageNumber=1&pageSize=10";
    }

    //保存新增/修改
    function saveMenu() {
        var data = {
            'menuId': $('#menuId').val(),
            'menuName': $('#menuName').val(),
            'menuDescription': $('#menuDescription').val(),
            'menuUrl': $('#menuUrl').val(),
            'menuParent': $('#menuParent').val(),
            'menuType':$('#menuType').val()
        }
        $.ajax({
            url: "/view/saveOrupdateMenu",
            type: "POST",
            dataType: "json",
            data: data,
            success: function (data) {
                if (data.data) {
                    window.location.href  = "/view/menuList?pageNumber=1&pageSize=10";
                }
            },
        });

    }


</script>

</body>
</html>